package org.compiere.model;

import java.io.File;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.util.Properties;

import org.compiere.process.DocAction;
import org.compiere.process.DocumentEngine;

public class MReconciliationAct extends X_FI_ReconciliationAct implements
		DocAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String		m_processMsg = null;
	public MReconciliationAct(Properties ctx) {
		super(ctx);

	}

	public MReconciliationAct(Properties ctx, int fI_ReconciliationAct_ID,
			String trx_name) {
		super(ctx, fI_ReconciliationAct_ID, trx_name);
	}

	public MReconciliationAct(Properties ctx, ResultSet rs, String trxName) {
		super(ctx, rs, trxName);
	}
	
	@Override
	public boolean processIt(String processAction) throws Exception {
		m_processMsg = null;
		DocumentEngine engine = new DocumentEngine (this, getDocStatus());
		return engine.processIt (processAction, getDocAction());
	}

	@Override
	public boolean unlockIt() {
		setProcessing(false);
		return true;
	}

	@Override
	public boolean invalidateIt() {		 
		setDocAction(DOCACTION_Prepare);
		return true;
	}

	@Override
	public String prepareIt() {		 
		return DocAction.STATUS_InProgress;
	}

	@Override
	public boolean approveIt() {		 
		return false;
	}

	@Override
	public boolean rejectIt() {		 
		log.info(toString());
		//setIsApproved(false);
		return true;
	}

	@Override
	public String completeIt() {		 
		if(this.isProcessed())
			this.setDocAction(this.getDocStatus());
		this.setProcessed(true);
			
		this.setDocStatus("CO");
		return DocAction.STATUS_Completed;
	}

	@Override
	public boolean voidIt() {		 
		return true;
	}

	@Override
	public boolean closeIt() {		
		this.setDocStatus(DOCSTATUS_Completed);
		return true;
	}

	@Override
	public boolean reverseCorrectIt() {		 
		return true;
	}

	@Override
	public boolean reverseAccrualIt() {		 
		return true;
	}

	@Override
	public boolean reActivateIt() {		 
		log.info("CMS Contract Bussines Process. reActivateIt()" + toString());
		log.info(toString());
		// Before reActivate
		m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE);
		if (m_processMsg != null)
			return false;	
		
		if (! reverseCorrectIt())
			return false;

		// After reActivate
		m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE);
		if (m_processMsg != null)
			return false;				
		setProcessed(false);
		return true;
	}

	@Override
	public String getSummary() {		 
		return null;
	}

	@Override
	public String getDocumentInfo() {		 
		return null;
	}

	@Override
	public File createPDF() {		 
		return null;
	}

	@Override
	public String getProcessMsg() {		 
		return null;
	}

	@Override
	public int getDoc_User_ID() {		 
		return 0;
	}

	@Override
	public BigDecimal getApprovalAmt() {		 
		return null;
	}

}
